
Location.prototype = new Array();

function Location(x, y){
	/** HERITAGE */
	this.parent = Array;
	this.parent();
	
	/** PRIVATE */
	this._constructor = function location__constructor(x, y){
		if (x < 0) { alert("Creating Location with: x < 0"); }
		if (x > 7) { alert("Creating Location with: x > 7"); }
		if (y < 0) { alert("Creating Location with: y < 0"); }
		if (y > 7) { alert("Creating Location with: y > 7"); }
		this[0] = x;			
		this[1] = y;
	}

	/** PUBLIC */
	this.getX = function location_getX(){
		return this[0];
	}

	this.setX = function location_setX(value){	
		this[0] = value;
	}

	this.getY = function location_getY(){
		return this[1];
	}

	this.setY = function location_setY(value){
		this[1] = value;
	}

	this.getSquareId = function location_getSquareId() {
		var result;
		result = "square_"+this[0]+"_"+this[1];
		return result;
	}

	this.setSquareId = function location_setSquareId(square_id) {
		var pos, result;
		pos = square_id;
		pos = pos.replace("square_","");
		this[0] = parseInt(pos.replace(/_[0-7]$/,""));
		this[1] = parseInt(pos.replace(/^[0-7]_/,""));
	}

	this.equals = function location_equals(loc_obj) { 
		var result;
		if ((this[0] == loc_obj[0])
				&& (this[1] == loc_obj[1])){
			result = true;
		} else {
			result = false;
		}
		return result;
	}

	this.toString = function location_toString(){
		var result;
		result = "[Location: ("+this[0]+", "+this[1]+")]";
		return result;
	}

	/** CONSTRUCT */
	this._constructor(x, y);
}
